import random
from collections import deque
from queue import Queue
from multiprocessing import Queue


class LoadBalancer:
    def __init__(self, instances):
        self.instances = deque(instances)

    def round_robin(self):
        self.instances.rotate(-1)
        return self.instances[0]

    def weighted_random(self, weights):
        return random.choices(self.instances, weights=weights)[0]